﻿

@{
    ViewBag.Title = "会议室管理";
    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}
@section styles{
    <link href="@Url.Content("~/Content/css/common/bootstrap-table/bootstrap-table.min.css")" rel="stylesheet" />
    <link href="@Url.Content("~/Content/css/common/animate/animate.min.css")" rel="stylesheet" />
}
<div id="dMain">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox" style="margin-bottom: 0px;">
            <div class="ibox-title">
                <h4>会议室管理</h4>
            </div>
            <div class="ibox-content">
                <from id="searchfrom">
                    <div class="dSearch">
                        <span>会议室名称</span>@Html.Editor("MR_NAME", new { htmlAttributes = new { @class = "input normal form-control", datatype = "*", nullmsg = " ", errormsg = " ", sucmsg = " " } })
                        <span>可容纳人数</span> @Html.Editor("MR_CAPACITY", new { htmlAttributes = new { Class = "input small form-control", datatype = "n", nullmsg = " ", errormsg = " ", sucmsg = " " } })
                        <span>是否支持视频会议</span><div class="rule-single-checkbox"><input type="checkbox" name="VIDEO_TYPE" class="form-control" value="false" /> </div>
                        <a id="lbtnSearch" class="btn btn-sm btn-primary btn-success" onclick="customSearch()"><i class="iconfont icon-sousuo"></i>&nbsp;快速检索</a>
                    </div>
                </from>
                <div id="toolbar">
                    <a class="btn btn-sm btn-success radius" onclick="parent.createTab('6201','新建会议室','@Url.Action("Edit","MeetingRoom",new { area="Meeting"})')" style="margin-top: 10px;"><i class="iconfont icon-tianjia"></i>&nbsp; 新建会议室</a>
                    <div class="text-danger" style="font-size: 14px; margin-top: 15px;margin-left: 10px;float:right; "><i class="iconfont icon-tuichiweixuan"></i>&nbsp;提示：双击行可查看该信息的详细！</div>
                </div>
                <table id="MeetingRoomDataTable"></table>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/bootstrap-table.min.js")"></script>
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/locale/bootstrap-table-zh-CN.min.js")"></script>
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/bootstrap-table-export.js")"></script>
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/tableExport.js")"></script>
    <script src="@Url.Content("~/Content/js/common/bootstrap-table/bootstrap-table-cookie.js")"></script>
    <script src="@Url.Content("~/Content/js/common/from.js")"></script>
    <script src="@Url.Content("~/Content/js/common/jqthumb.js")"></script>
    <script>
    //var tabHeight = 0;
        $(function () {
            $('#MeetingRoomDataTable').bootstrapTable({
                //  height: tabHeight + 50,
                url: '/MeetingRoom/GetTableJsonResult',         //请求后台的URL（*）
                method: 'get',                      //请求方式（*）
                //data: $("#dJson").text() != "" ? JSON.parse($("#dJson").text()) : "",
                dataType: "json",
                columns: [
                    { checkbox: true },
                    {
                        title: "会议室名称", field: 'MR_NAME', valign: 'middle', align: 'center'
                    },
                    {
                        title: "可容纳人数", field: 'MR_CAPACITY', valign: 'middle',align: 'center'
                    },
                    {
                        title: "地址", field: 'MR_PLACE', valign: 'middle',align: 'center'
                    },
                    {
                        title: "会议室管理员", field: 'OPERATOR', valign: 'middle', align: 'center'
                    },
                    {
                        title: "是否支持视频会议", field: 'VIDEO_TYPE', valign: 'middle', align: 'center', formatter: function (value, row, index) {
                            if (value == "1") {
                                return '<span>是</span>';
                            }
                            else { return '<span>否</span>'; }
                        }
                    },
                    {
                        title: "会议室图片", field: 'MR_IMAGE', valign: 'middle',align: 'center', formatter: function (value, row, index) {
                            return `<img class="showimg" style="width:100px;" src="${value}">`;
                        }
                    },
                    {
                        field: '#',
                        title: "操作",
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            var ids = row.MR_ID;
                            return '<a class="btn btn-info btn-xs btn-outline" onclick="parent.createTab(\'6201\',\'编辑会议室\',\'@Url.Action("Edit", "MeetingRoom", new { area = "Meeting" })\/' + ids + '\')">编辑</a>  <a class=" btn btn-danger btn-xs  " onclick="del(' + ids + ')">删除</a>';
                        }
                    }
                ],
                toolbar: '#toolbar',//工具按钮用哪个容器
                buttonsClass: "sm btn-white",//按钮class
                pageSize: 10,//分页条数
                clickToSelect: false,//设置true 将在点击行时，自动选择单选或复选框
                singleSelect: false,//为true则禁止多选
                cache: false,//是否缓存
                cookie: true,//是否启用cookie
                cookieIdTable: "MeetingRoom",//cookie键值
                pagination: true,//是否分页
                showColumns: true,//是否显示所有的列
                showRefresh: true,//是否显示刷新按钮
                search: false,//是否启用搜索
                showPaginationSwitch: true,//是否显示分页切换按钮
                showExport: true,//是否启用导出
                striped: false,//是否显示行间隔色
                detailView: false,//是否显示切换视图列
                queryParams: function (params) {
                    var param = {};
                    //var arr = $("form").serialize();
                    //$.param(arr);
                    //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                    $('.dSearch').find('[name]').each(function () {
                        var value = $(this).val();
                        if (value != '') {
                            //if (!param.find($(this).attr('name')))
                            param[$(this).attr('name')] = value;
                        }
                    });

                    return param;
                },
                //checkbox水平居中
                onLoadSuccess: function () {
                    $(".bs-checkbox").css({ 'text-align': 'center', 'vertical-align': 'middle' });},
                //detailFormatter: detailFormatter,//卡片视图内容格式化
                onDblClickRow: function (row, obj) { //双击行事件
                    // window.top.showFullPage("图像阅读器（" + (row.FileNo) + "）", "/See.aspx?FID=" + row.ID);
                    parent.createTab('6203', '会议室明细', '@Url.Action("MeetingRoomDetails", "MeetingRoom", new { area = "Meeting" })/' + row.MR_ID + '');
                },
                onClickRow: function (row, obj) { //单击行事件
                    $(obj).parent().find("tr").removeClass("selected");
                    $(obj).addClass("selected");

                    ////根据选中的行获取子表数据
                    //GetSonData(row.ID);
                },
                onSearch: function (text) {
                    if (text != "") {
                        $("#tabData tbody tr td:not(.bs-checkbox)").each(function (i) {
                            var str = "<span class=\"bg-yellow\">" + text + "</span>";
                            var NewText = $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).text().replaceAll(text, str);
                            $("#tabData tbody tr td:not(.bs-checkbox)").eq(i).html(NewText);
                        })
                    }
                }
            });
            showimg();
        })
        function showimg() {

            $('.showimg').jqthumb({
                classname: 'jqthumb',
                width: '100%',
                height: 60,
                position: { y: '35%', x: '43%' },
                zoom: 3,
                show: false,
                before: function (oriImage) { },
                after: function (imgObj) {
                    fadeIn($(imgObj));
                }
            });}
        function customSearch(text) {
            $('#MeetingRoomDataTable').bootstrapTable('refresh');//刷新Table，Bootstrap Table 会自动执行重新查询
        }
        function getName(arr, n, v) {
            for (var i = 0; i < arr.length; i++)
                if (arr[i][n] == v)
                    return arr[i]["Text"];
        }

           function del(id) {
            layer.confirm('是否删除此会议室？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                var url = '@Url.Action("Delete", "MeetingRoom", new { area = "Meeting" })\/' + id;
                $.get(url, function (result) {
                    $("#MeetingRoomDataTable").bootstrapTable('refresh', { url: '/MeetingRoom/GetTableJsonResult'});
                    layer.msg('删除会议室成功！',{ icon: 1,
                        time: 2000//2s后自动关闭
                    });
                });
            }, function () {

            });
        }
    </script>
}